package ControlLayer;



import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The test class UnitTest.
 *
 * @author  (your name)
 * @version (a version number or a date)
 */
public class UnitTest
{
    private ControlLayer.AddressCtr addressC1;
    private ControlLayer.DVDCtr dVDCtr1;
    private ControlLayer.LoanCtr loanCtr1;

    /**
     * Default constructor for test class UnitTest
     */
    public UnitTest()
    {
    }

    /**
     * Sets up the test fixture.
     *
     * Called before every test case method.
     */
    @Before
    public void setUp()
    {
        addressC1 = new ControlLayer.AddressCtr();
        dVDCtr1 = new ControlLayer.DVDCtr();
        loanCtr1 = new ControlLayer.LoanCtr();
    }

    /**
     * Tears down the test fixture.
     *
     * Called after every test case method.
     */
    @After
    public void tearDown()
    {
    }

    @Test
    public void testCreatePerson()
    {
        addressC1.createPerson("test1", "test1" , "test1", "test1", "test1", "test1");
        addressC1.createPerson("test2", "test2", "test2", "test2", "test2", "test2");
        addressC1.createPerson("test3", "test3", "test3", "test3", "test3", "test3");
        addressC1.createPerson("test4", "test4","test4","test4","test4","test4");
        
    }

    @Test
    public void testDeletePerson()
    {
        assertEquals(true, addressC1.deletePerson("test1"));
    }

    @Test
    public void testFindLoaner()
    {
        assertNotNull(loanCtr1.findLoaner("test2"));
    }

    @Test
    public void testFindPerson()
    {
        assertNotNull(addressC1.findPersonID("test2"));
    }

    @Test
    public void testFindPersonByName()
    {
        assertNotNull(addressC1.findPersonName("test2"));
        assertNotNull(addressC1.findPersonName("test3"));
    }


    @Test
    public void testListAll()
    {
        assertNotNull(dVDCtr1.listAllDvds());
    }

    @Test
    public void testUpdatePerson()
    {
        addressC1.updatePerson( "test4", "test4", "test4", "test4", "test4", "66554411");
    }

    @Test
    public void testCreateDVD()
    {
        dVDCtr1.createDVD("Die Hard 1", "Bruce Willis", "1994");
        dVDCtr1.createDVD("Die Hard 2", "Bruce Willis", "1996");
        dVDCtr1.createDVD("Die Hard 3", "Bruce Willis", "1998");
        dVDCtr1.createDVD("Die Hard 4", "Bruce Willis", "2008");
    }

    @Test
    public void testCreateCopy()
    {
        dVDCtr1.createCopy(1, 11, "10-10-2008", 50);
        dVDCtr1.createCopy(1, 12, "10-10-2010", 50);
        dVDCtr1.createCopy(2, 21, "10-10-2010", 50);
        dVDCtr1.createCopy(3, 31, "10-10-2010", 50);
        dVDCtr1.createCopy(4, 41, "10-10-2010", 150);
    }


   

    @Test
    public void testFindCopy()
    {
        assertNotNull(loanCtr1.findCopy("Die Hard 3"));
    }

    @Test
    public void testDeleteDVD()
    {
        assertEquals(true, dVDCtr1.deleteDVD(1));
    }

    @Test
    public void testCreateLoan()
    {
        loanCtr1.createLoan("test2", "Die Hard 3", "from", "to");
        assertNotNull(loanCtr1.findLoan("test2"));
    }
}































